/*
 * 版权所有 (C) 2015 知启蒙(ZHIQIM) 保留所有权利。[遇见知启蒙，邂逅框架梦]
 * 
 * https://zhiqim.org/project/zhiqim_framework/zhiqim_orm.htm
 *
 * Zhiqim Orm is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
package org.zhiqim.orm.dbo.defined;

import org.zhiqim.kernel.util.Validates;
import org.zhiqim.orm.ORMConstants;

/**
 * 视图连接条件格式，支持以下四种格式，配置格式如：<br><br>
 * 1.左表列=右表列<join type="EQUAL" lTable="USER" lColumn="USER_ID" rTable="USER_EX" rColumn="USER_ID"/><br>
 * 2.左表列 left join in 右表列<where type="LEFT" lTable="USER" lColumn="USER_ID" rTable="USER_EX" rColumn="USER_ID"/><br>
 * 3.左表列 right join in 右表列<where type="RIGHT" lTable="USER" lColumn="USER_ID" rTable="USER_EX" rColumn="USER_ID"/><br>
 * 4.左表列=固定值<where type="RIGHT" lTable="USER" lColumn="USER_ID" rValue="zouzhigang"/>
 * 
 * @version v1.0.0 @author zouzhigang 2014-3-21 新建与整理
 */
public class _ViewJoin implements ORMConstants
{
    private String type;
    
    private String lTable;
    private String lColumn;
    private String rTable;
    private String rColumn;
    private String rValue;
    
    public _ViewJoin(String type, String lTable, String lColumn, String rTable, String rColumn, String rValue)
    {
        this.type = type;
        this.lTable = lTable;
        this.lColumn = lColumn;
        this.rTable = rTable;
        this.rColumn = rColumn;
        this.rValue = rValue;
    }
    
    public String toString()
    {
        StringBuilder strb = new StringBuilder("<join");
        strb.append(" type=").append(_DOUBLE_QUOTE_).append(type).append(_DOUBLE_QUOTE_);
        strb.append(" lTable=").append(_DOUBLE_QUOTE_).append(lTable).append(_DOUBLE_QUOTE_)
            .append(" lColumn=").append(_DOUBLE_QUOTE_).append(lColumn).append(_DOUBLE_QUOTE_);
        
        if (Validates.isNotEmpty(rColumn))
            strb.append(" rTable=").append(_DOUBLE_QUOTE_).append(rTable).append(_DOUBLE_QUOTE_)
            .append(" rColumn=").append(_DOUBLE_QUOTE_).append(rColumn).append(_DOUBLE_QUOTE_);
        else
            strb.append(" rValue=").append(_DOUBLE_QUOTE_).append(rValue).append(_DOUBLE_QUOTE_);
        
        return strb.append("/>").toString();
    }
    
    public String getType()
    {
        return type;
    }
    public String getLTable()
    {
        return lTable;
    }
    public String getLColumn()
    {
        return lColumn;
    }
    public String getRTable()
    {
        return rTable;
    }
    public String getRColumn()
    {
        return rColumn;
    }
    public String getRValue()
    {
        return rValue;
    }
}
